package com.flx.at.spring.code.test.testbeanregister;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * @Author: Fenglixiong
 * @Date: 2021/7/3 11:52
 * @Description:
 */
@Slf4j
@ComponentScan(basePackages = "com.flx.at.spring.code.test.testbeanregister")
public class MainApp {

    public static void main(String[] args) {

        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MainApp.class);
        String[] beanDefinationNames = ctx.getBeanDefinitionNames();
        for(String name : beanDefinationNames){
            System.out.println("[Spring Loader Bean]："+name);
        }
        //获取通过bean工厂形式创建的bean
        System.out.println(ctx.getBean("myFactoryBean"));
        //获取通过bean工厂本身
        System.out.println(ctx.getBean("&myFactoryBean"));
    }

}
